{include file='common/head.html'}

<div class="layui-body">
	{if([$list])}
	<div class="layui-tab layui-tab-brief" lay-filter="tab">
	  <ul class="layui-tab-title">
	    <li class="layui-this" lay-id="t1">广告列表</li>
	    <li lay-id="t2">添加广告</li>
	  </ul>
	  <div class="layui-tab-content">
	  	<div class="layui-tab-item layui-show">
            <form action="{url./admin/Slide/index}" method="get" class="layui-form">
                {$pathinfo}
                <div class="layui-form-item nospace">
                    <div class="layui-input-inline">
                        <input type="text" name="keyword"  value="{$get.keyword}"  placeholder="请输入广告标题" class="layui-input">
                    </div>
                    <div class="layui-input-inline">
                        <select name="status">
                            <option value="">请选择状态</option>
                            {$status_select}
                        </select>
                    </div>
                    <div class="layui-input-inline">
                        <select id="position" name="position">
                            <option value="">请选择广告位置</option>
                            {$position_select}
                        </select>
                    </div>

                    <div class="layui-input-inline">
                        <select id="time_category" name="time_category">
                            <option value="">请选择有效期...</option>
                            {$time_category_select}
                        </select>
                    </div>

                    <div class="layui-input-inline">
                        <button class="layui-btn" lay-submit>搜索</button>
                        <a class="layui-btn layui-btn-primary"  href="{url./admin/Slide/index}">清除搜索</a>
                    </div>
                </div>


            </form>

            <form action="{url./admin/Slide/mod}" method="post" class="layui-form" id="contentForm" name="contentForm"  onkeydown="if(event.keyCode==13) return false;">
                <input type="hidden" name="formcheck" value="{$formcheck}" >
                <table class="layui-table">
                    <thead>
                    <tr>
                        <th><input type="checkbox" class="checkbox" lay-ignore id="checkall" title="全选"></th>
                        <th>ID</th>
                        <th>广告标题</th>
                        <th>详情</th>
                        <th>广告位置</th>
                        <th>排序</th>
                        <th>状态</th>
                        <th>图片路径</th>
                        <th>图片宽度</th>
                        <th>图片高度</th>
                        <th>图片链接</th>
                        <th>生效时间</th>
                        <th>结束时间</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    {foreach $slides(key,value)}
                    <tr>
                        <td>
                            <input type="checkbox" class="checkbox checkitem" lay-ignore name="list[]" value="[value->id]">
                            <input type="hidden" name="listall[]" value="[value->id]">
                        </td>
                        <td>[value->id]</td>
                        <td>[value->title]</td>
                        <td>[value->subtitle]</td>
                        <td>
                            {fun=get_slide_position($value->position)}
                        </td>
                        <td class="table-input">
                            <input type="hidden" name="listall[]" value="[value->id]">
                            <input type="text" lay-ignore class="layui-input" name="sorting[]" value="[value->sorting]">
                        </td>
                        <td>
                            {if($value->status)}
                            <a href="{url./admin/'.C.'/mod/id/'.$value->id.'/field/status/value/0}" class="switch"><i class='fa fa-toggle-on' title="点击关闭"></i></a>
                            {else}
                            <a href="{url./admin/'.C.'/mod/id/'.$value->id.'/field/status/value/1}" class="switch"><i class='fa fa-toggle-off' title="点击开启"></i></a>
                            {/if}
                        </td>                        <td><img src="{SITE_DIR}[value->pic]" style="height:30px;"></td>
                        <td>[value->image_width]</td>
                        <td>[value->image_height]</td>
                        <td>[value->link]</td>
                        <td>[value->start_time]</td>
                        <td>[value->end_time]</td>
                        <td>
                            {fun=get_btn_del($value->id)}
                            {fun=get_btn_mod($value->id)}
                        </td>
                    </tr>
                    {/foreach}
                    </tbody>
                </table>
                <div class="layui-btn-group">
                    {if(check_level('del'))}
                    <button type="submit" name="submit" onclick="return setDelAction();" class="layui-btn layui-btn-sm">批量删除</button>
                    {/if}
                    {if(check_level('mod'))}
                    <button type="submit" name="submit" value="sorting" class="layui-btn layui-btn-sm">保存排序</button>
                    {/if}
                </div>
                <script>
                    function setDelAction(){
                        document.contentForm.action = "{url./admin/Content/del}";
                        return confirm("您确定要删除选中的内容么？");
                    }
                </script>
            </form>
            <div class="page">{$pagebar}</div>
	  	</div>
	  	
	  	<div class="layui-tab-item">
	  		<form action="{url./admin/Slide/add}" method="post" class="layui-form">
	  			<input type="hidden" name="formcheck" value="{$formcheck}" >

                <div class="layui-form-item">
                    <label class="layui-form-label"><span style="color:red;">*</span>广告标题</label>
                    <div class="layui-input-block">
                        <input type="text" lay-verify="required" name="title" placeholder="请输入标题"  class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"><span style="color:red;">*</span>广告位置</label>
                    <div class="layui-input-block">
                        <select id="position" name="position">
                            <option value="">请选择广告位置</option>
                            {$position_select}
                        </select>
                    </div>
                </div>

                <div class="layui-form-item">
                     <label class="layui-form-label">广告图片</label>
                     <div class="layui-input-inline">
                     	<input type="text" name="pic" id="pic" required  lay-verify="required" placeholder="请上传图片"  class="layui-input">
                     </div>
                     <button type="button" class="layui-btn upload" data-des="pic">
					 	 <i class="layui-icon">&#xe67c;</i>上传图片
					 </button>
					 <div id="pic_box" class="pic"></div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">图片尺寸</label>
                    <div class="layui-input-block">
                        <div class="layui-input-inline" style="width: 100px;">
                            <input type="text" name="image_width"  value=""  placeholder="宽" class="layui-input">
                        </div>
                        <div class="layui-form-mid">×</div>
                        <div class="layui-input-inline" style="width: 100px;">
                            <input type="text" name="image_height"  value=""  placeholder="高" class="layui-input">
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">有效期</label>
                    <div class="layui-input-block">
                        <div class="layui-input-inline" style="width: 100px;">
                            <input type="text" name="start_time" id="start_time" placeholder="开始时间" autocomplete="off" class="layui-input" />
                        </div>
                        <div class="layui-form-mid">至</div>
                        <div class="layui-input-inline" style="width: 100px;">
                            <input type="text" name="end_time" id="end_time" placeholder="结束时间" autocomplete="off" class="layui-input" />
                        </div>
                        <button type="button" class="layui-btn" name="max_time" onclick="maxtime()">
                            无期限生效按钮
                        </button>
                    </div>
                </div>

                <div class="layui-form-item">
                     <label class="layui-form-label">广告链接</label>
                     <div class="layui-input-block">
                     	<input type="text" name="link" placeholder="请输入跳转链接"  class="layui-input">
                     </div>
                </div>

                <div class="layui-form-item">
                     <label class="layui-form-label">排序</label>
                     <div class="layui-input-block">
                     	<input type="text" name="sorting" required lay-verify="required" value="255" placeholder="请输入排序"  class="layui-input">
                     </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">详情</label>
                    <div class="layui-input-block">
                        <textarea id="subtitle" name="subtitle" placeholder="请输入详情" class="layui-textarea"></textarea>
                    </div>
                </div>

                 <div class="layui-form-item">
					 <div class="layui-input-block">
					    <button class="layui-btn" lay-submit>立即提交</button>
					    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
					 </div>
				</div>
	  		</form>
	  	</div>
	  </div>
	</div>
	{/if} 
	
	{if([$mod])}
	<div class="layui-tab layui-tab-brief" lay-filter="tab">
	  <ul class="layui-tab-title">
	    <li class="layui-this">广告修改</li>
	  </ul>
	  <div class="layui-tab-content">
	  	<div class="layui-tab-item layui-show">
	  		<form action="{url./admin/Slide/mod/id/'.[$get.id].'}{$backurl}" method="post" class="layui-form">
	  			<input type="hidden" name="formcheck" value="{$formcheck}" >

                <div class="layui-form-item">
                    <label class="layui-form-label"><span style="color:red;">*</span>广告标题</label>
                    <div class="layui-input-block">
                        <input type="text" lay-verify="required" name="title" value="{$slide->title}" placeholder="请输入标题"  class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"><span style="color:red;">*</span>广告位置</label>
                    <div class="layui-input-block">
                        <select id="position" name="position">
                            <option value="">请选择广告位置</option>
                            {$position_select}
                        </select>
                    </div>
                </div>
                
                <div class="layui-form-item">
                     <label class="layui-form-label">图片</label>
                     <div class="layui-input-inline">
                     	<input type="text" name="pic" id="pic" required  lay-verify="required" value="{$slide->pic}" placeholder="请上传图片"  class="layui-input">
                     </div>
                     <button type="button" class="layui-btn upload" data-des="pic">
					 	 <i class="layui-icon">&#xe67c;</i>上传图片
					 </button>
					 <div id="pic_box" class="pic">{if([$slide->pic])}<dl><dt><img src="{SITE_DIR}{$slide->pic}" data-url="{$slide->pic}"></dt><dd>删除</dd></dl>{/if}</div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">图片尺寸</label>
                    <div class="layui-input-block">
                        <div class="layui-input-inline" style="width: 100px;">
                            <input type="text" name="image_width"  value="{$slide->image_width}"  placeholder="宽" class="layui-input">
                        </div>
                        <div class="layui-form-mid">×</div>
                        <div class="layui-input-inline" style="width: 100px;">
                            <input type="text" name="image_height"  value="{$slide->image_height}"  placeholder="高" class="layui-input">
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">有效期</label>
                    <div class="layui-input-block">
                        <div class="layui-input-inline" style="width: 100px;">
                            <input type="text" name="start_time" id="start_time" value="{$slide->start_time}" placeholder="开始时间" autocomplete="off" class="layui-input" />
                        </div>
                        <div class="layui-form-mid">至</div>
                        <div class="layui-input-inline" style="width: 100px;">
                            <input type="text" name="end_time" id="end_time"  value="{$slide->end_time}" placeholder="结束时间" autocomplete="off" class="layui-input" />
                        </div>
                        <button type="button" class="layui-btn" name="max_time" onclick="maxtime()">
                            无期限生效按钮
                        </button>
                    </div>
                </div>


                <div class="layui-form-item">
                     <label class="layui-form-label">跳转链接</label>
                     <div class="layui-input-block">
                     	<input type="text" name="link" value="{$slide->link}"  placeholder="请输入跳转链接"  class="layui-input">
                     </div>
                </div>


                 <div class="layui-form-item">
                     <label class="layui-form-label">排序</label>
                     <div class="layui-input-block">
                     	<input type="text" name="sorting" required lay-verify="required" value="{$slide->sorting}" placeholder="请输入排序"  class="layui-input">
                     </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">详情</label>
                    <div class="layui-input-block">
                        <textarea id="subtitle" name="subtitle" placeholder="请输入详情" class="layui-textarea">{$slide->subtitle}</textarea>
                    </div>
                </div>


                <div class="layui-form-item">
					 <div class="layui-input-block">
					    <button class="layui-btn" lay-submit>立即提交</button>
					    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
					    {fun=get_btn_back()}
					 </div>
				</div>
	  		</form>
	  	</div>
	  </div>
	</div>
	{/if}
</div>

{include file='common/foot.html'}
<script>

</script>
